package com.prs.moa.workflow.service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;

import com.prs.moa.workflow.model.Message;
import com.prs.moa.workflow.model.Person;



public class HelloWorld {

	public Message sayHello(Person person) {
		System.out.println("----------->start");
		Message message = new Message();
		if (null == person.getName() || "".equals(person.getName())) {
			message.setCode("1");
			message.setMessage("你好");
			System.out.println("----------->end1");
			return message;
		}

		if (null == person.getAge()) {
			message.setCode("2");
			message.setMessage("你好");
			System.out.println("----------->end2");
			return message;
		}

		message.setCode("0");
		message.setMessage("你好," + person.getName() + "你好"
				+ person.getAge());
		System.out.println("----------->end");
		return message;
	}

	public String sayWhy(String name) {
		System.out.println("----------->start");
		return name;
	}

	@SuppressWarnings("unchecked")
	public OMElement sayTest(OMElement omElement) throws AxisFault {
		MessageContext messageContext = MessageContext
				.getCurrentMessageContext();
		OMElement header = messageContext.getEnvelope().getHeader();
		Map<String, Object> hashMap = new HashMap<String, Object>();
		for (Iterator<OMElement> iterator = header.getChildElements(); iterator
				.hasNext();) {
			OMElement type = (OMElement) iterator.next();
			hashMap.put(type.getLocalName(), type.getText());
		}
//		MessageInfo messageInfo = new MessageInfo();
//		Object aa = BeanUtil.processObject(omElement, MessageInfo.class, null,
//				true, new DefaultObjectSupplier(),
//				);
		System.out.println(header);
		System.out.println(omElement);

		return null;
	}

	public void sayHow() {
		System.out.println("aaa");
	}
}
